package com.itcast.spring6.ioc.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 需要初始化的Bean 初始化Bean的顺序参考序号
 * 销毁Bean，spring上下文关闭之前销毁，销毁Bean的顺序参考序号
 * @author zhangtian105
 * @date 2023/4/27
 * @apiNote
 */
@Slf4j
public class InitialzationBean implements InitializingBean, DisposableBean {
    @PostConstruct
    public void init() {
        log.info("1、InitialzationBean init init .....");
    }

    public void initInitialzationBean() {
        log.info("3、InitialzationBean initInitialzationBean init ......");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("2、InitialzationBean afterPropertiesSet init ......");
    }

    @PreDestroy
    public void destory() {
        log.info("1、InitialzationBean destory destory ......");
    }

    public void destoryInitialzationBean() {
        log.info("3、InitialzationBean destoryInitialzationBean destory ......");
    }

    @Override
    public void destroy() throws Exception {
        log.info("2、InitialzationBean destroy destory ......");
    }
}
